******************
*** PANELS A,D ***
******************
clear all 
set more off
cd "/Users/yasenov/Dropbox/mariel_boatlift/jhr_version/jhr_figures"
global folder /Users/yasenov/Dropbox/mariel_boatlift/revision_version/revision_data/
set scheme s1color

use $folder/aux_march.dta

keep if age >= 19 & age <= 65
keep if low_skilled == 1
keep if hispan != 300
keep if labforce == 2
drop if classwly == 10 | classwly == 13 | classwly == 14 

collapse (mean) logwage weeksunemp [pw=wtsupp], by(year metarea)
replace year = year - 1  
merge 1:1 year metarea using $folder/msa_controls_march.dta, nogenerate

keep if logwage != . 
keep if year >= 1972
bysort metarea: gen num_year = _N
keep if num_year == 19
xtset metarea year

local controls logwage(1979) logwage logwage(1974) low_skilled hisp manuf
synth logwage `controls', trunit(5000) trperiod(1980) nested keep(fig6a.dta, replace)

local controls weeksunemp weeksunemp(1972) weeksunemp(1975) low_skilled hisp manuf
synth weeksunemp `controls', trunit(5000) trperiod(1980) nested keep(fig6d.dta, replace)

use fig6a, clear
rename (_time _Y_treated _Y_synthetic) (year miami synthetic)
keep if year != .
twoway (line miami year, lcolor(black) lpattern(solid)) ///
	(line synthetic year, lcolor(black) lpattern(dash)), ///
	xline(1979, lcolor(black) lpattern(dash)) ///
	xtitle("") ///
	ytitle("") ///
	legend(label(1 "Miami") label(2 "Synthetic Miami")) ///
	subtitle("Log Weekly Wages") ///
	xlabel(1973 "1973" 1975 "75" 1977 "77" 1979 `""79" "Pre""' 1981 `""81" "Post""' 1983 "83" 1985 "85" 1987 "87" 1989 "89" 1991 "91") ///
	xscale(range(1972 1991)) ///
	yscale(range(4.8 5.3)) ///
	ylabel(4.8(.1)5.3) ///
	text(5.4 1989.3 "Panel A")  nodraw plotregion(lwidth(none))

graph copy one, replace

use fig6d, clear
rename (_time _Y_treated _Y_synthetic) (year miami synthetic)
keep if year != .
twoway (line miami year, lcolor(black) lpattern(solid)) ///
	(line synthetic year, lcolor(black) lpattern(dash)), ///
	xline(1979, lcolor(black) lpattern(dash)) ///
	xtitle("") ///
	ytitle("") ///
	legend(label(1 "Miami") label(2 "Synthetic Miami") size(small)) ///
	subtitle("Unemployment") ///
	xlabel(1973 "1973" 1975 "75" 1977 "77" 1979 `""79" "Pre""' ///
	1981 `""81" "Post""' 1983 "83" 1985 "85" 1987 "87" 1989 "89" 1991 "91") ///
	xscale(range(1972 1992)) ///
	text(.4 1990.8 "Panel D")  nodraw  plotregion(lwidth(none))

graph copy four, replace

*******************
*** PANELS B,C ****
*******************
clear
use $folder/aux_march.dta

keep if age >= 19 & age <= 65
keep if hispan != 300
keep if labforce == 2
drop if classwly == 10 | classwly == 13 | classwly == 14 

collapse (p15) p15logwage=logwage (p20) p20logwage=logwage [pw=wtsupp], by(year metarea)
replace year = year - 1  
merge 1:1 year metarea using $folder/msa_controls_march.dta, nogenerate

keep if p15logwage != . 
keep if year >= 1972
bysort metarea: gen num_year = _N
keep if num_year == 19
xtset metarea year

local controls p15logwage p15logwage(1976) low_skilled hisp manuf
synth p15logwage `controls', trunit(5000) trperiod(1980) nested keep(fig6b.dta, replace)

local controls p20logwage p20logwage(1976) low_skilled hisp manuf
synth p20logwage `controls', trunit(5000) trperiod(1980) nested keep(fig6c.dta, replace)

use fig6b, clear
rename (_time _Y_treated _Y_synthetic) (year miami synthetic)
keep if year != .
twoway (line miami year, lcolor(black) lpattern(solid)) ///
	(line synthetic year, lcolor(black) lpattern(dash)), ///
	xline(1979, lcolor(black) lpattern(dash)) ///
	xtitle("") ///
	ytitle("") ///
	legend(label(1 "Miami") label(2 "Synthetic Miami")) ///
	subtitle("15th Percentile Log Weekly Wages") ///
	xlabel(1973 "1973" 1975 "75" 1977 "77" 1979 `""79" "Pre""' 1981 `""81" "Post""' 1983 "83" 1985 "85" 1987 "87" 1989 "89" 1991 "91") ///
	xscale(range(1972 1991)) ///
	text(4.9 1989.4 "Panel B")  nodraw plotregion(lwidth(none))

graph copy two, replace

use fig6c, clear
rename (_time _Y_treated _Y_synthetic) (year miami synthetic)
keep if year != .
twoway (line miami year, lcolor(black) lpattern(solid)) ///
	(line synthetic year, lcolor(black) lpattern(dash)), ///
	xline(1979, lcolor(black) lpattern(dash)) ///
	xtitle("") ///
	ytitle("") ///
	legend(label(1 "Miami") label(2 "Synthetic Miami")) ///
	subtitle("20th Percentile Log Weekly Wages") ///
	xlabel(1973 "1973" 1975 "75" 1977 "77" 1979 `""79" "Pre""' 1981 `""81" "Post""' 1983 "83" 1985 "85" 1987 "87" 1989 "89" 1991 "91") ///
	xscale(range(1972 1991)) ///
	yscale(range(4.6 5.1)) ///
	ylabel(4.6(.1)5.1) ///
	text(5.1 1989.4 "Panel C") nodraw  plotregion(lwidth(none))

graph copy three, replace

grc1leg one two three four, imargin(vsmall) legendfrom(four)
graph export "jhr_fig6.pdf", replace
